export function debounce(func: any, delay: number) {
  let timeoutId: any;

  return function (...args: any) {
    if (timeoutId) {
      clearTimeout(timeoutId);
    }

    timeoutId = setTimeout(() => {
      func.apply(this, args);
    }, delay);
  };
}

export function objectWithEmpty(obj: any) {
  let copy = Object.assign({}, obj);
  Object.keys(obj).forEach((key) => {
    if (!obj[key]) delete copy[key];
  });
  return copy;
}
